VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsUsuario"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit

Private usrCodigo&
Private usrNombre$
Private usrClave$
Private usrDiestro As Boolean
Private usrFoto As Picture


Public Property Get Nombre() As String
  Nombre = usrNombre$
End Property

Public Property Let Codigo(vData As Integer)
  cargaUsr vData
End Property

Public Property Get Codigo() As Integer
  Codigo = usrCodigo&
End Property

Public Property Get Clave() As String
  Clave = usrClave$
End Property

Public Property Get Diestro() As Boolean
    Diestro = usrDiestro
End Property

Public Property Let Foto(vData As Picture)
 Set usrFoto = vData
End Property

Public Property Get Foto() As Picture
  Set Foto = usrFoto
End Property

Public Function verifyPermiso(ByVal codPermiso As Long) As Boolean
Dim rs_usuarios As ADODB.Recordset
  Dim sqlStr$
    Set rs_usuarios = New ADODB.Recordset
    sqlStr$ = "SELECT COUNT(Codigo) AS Existe FROM  [Usuarios (Permisos)]" & _
                 "WHERE [Usuarios (Permisos)].idPermiso = " & codPermiso & _
                 " AND [Usuarios (Permisos)].Codigo = " & usrCodigo

    rs_usuarios.CursorLocation = adUseServer
    rs_usuarios.Open sqlStr$, Cn_Local, adOpenStatic, adLockReadOnly
    
    verifyPermiso = CBool(rs_usuarios.Fields("Existe"))

    If rs_usuarios.State = ADODB.adStateOpen Then rs_usuarios.Close
    Set rs_usuarios = Nothing
End Function

Private Sub cargaUsr(ByVal codeUsr As Integer)
Dim rs_usuarios As ADODB.Recordset
  Dim sqlStr$
    Set rs_usuarios = New ADODB.Recordset
    sqlStr$ = "SELECT Codigo, Nombre, Clave, Diestro FROM  Usuarios " & _
                 "WHERE Codigo = " & codeUsr

    With rs_usuarios
        .CursorLocation = adUseServer
        .Open sqlStr$, Cn_Local, adOpenStatic, adLockReadOnly
        usrCodigo& = rs_usuarios.Fields("Codigo")
        usrNombre$ = rs_usuarios.Fields("Nombre") & vbNullString
        usrClave$ = rs_usuarios.Fields("Clave") & vbNullString
        usrDiestro = rs_usuarios.Fields("Diestro")
        If .State = ADODB.adStateOpen Then .Close
    End With

    Set rs_usuarios = Nothing

End Sub

Public Sub Clear()
  Class_Initialize
End Sub

Private Sub Class_Initialize()
  Set usrFoto = Nothing
  usrCodigo& = 0
  usrNombre$ = "noname"
  usrClave$ = vbNullString
  usrDiestro = True
End Sub

Private Sub Class_Terminate()
  Set usrFoto = Nothing
End Sub
